package com.becca.cake.model.users;

import java.io.Serializable;
import java.util.Date;

import com.becca.cake.core.exception.ServiceException;
import com.becca.cake.util.StringUtil;

/**
 * 用户地址实体
 * @copyright  尊星(上海)信息科技有限公司
 * @author hejinguo
 * @date 2016年4月10日 上午3:53:35
 */
public class UserAddressModel implements Serializable {
    /**  */
    private static final long  serialVersionUID         = 6798565153454449439L;

    /**收货人姓名不能为空*/
    public static final String CONSIGNEE_NOE_NULL       = "收货人姓名不能为空";
    /**收货人电话不能为空*/
    public static final String CONSIGNEE_PHONE_NOE_NULL = "收货人电话不能为空";
    /**省份名称不能为空*/
    public static final String PROVINCE_NAME_NOE_NULL   = "省份名称不能为空";
    /**城市名称不能为空*/
    public static final String CITY_NAME_NOE_NULL       = "城市名称不能为空";
    /**区县名称不能为空*/
    public static final String DISTRICET_NAME_NOE_NULL  = "区县名称不能为空";
    /**详细地址不能为空*/
    public static final String ADDRESS_NOE_NULL         = "详细地址不能为空";
    /**收货地址编号不能为空*/
    public static final String ID_IS_NULL               = "收货地址编号不能为空";
    /**该地址已被禁用*/
    public static final String ADDRESS_IS_FORBIDDEN     = "该地址已被禁用";
    /**该地址已默认*/
    public static final String ADDRESS_IS_DEFAULT       = "该地址已默认";

    /**状态(0:正常 )*/
    public static final Byte   ADDRESS_STATUS_ENABLE    = 0;
    /**状态(1:删除 )*/
    public static final Byte   ADDRESS_STATUS_DISABLE   = 1;

    /**是否默认(0:不默认 )*/
    public static final Byte   ADDRESS_NO_DEFAULT       = 0;
    /**是否默认(1:默认)*/
    public static final Byte   ADDRESS_DEFAULT          = 1;

    private Integer            id;
    /**用户ID*/
    private Integer            userId;
    /**收货人姓名*/
    private String             consignee;
    /**收货人手机号*/
    private String             consignPhone;
    /**省份名称*/
    private String             provinceName;
    /**城市名称*/
    private String             cityName;
    /**区县名称*/
    private String             districtName;
    /**详细地址*/
    private String             address;
    /**是否删除(0:不删除 1:已删除)*/
    private Byte               status;
    /**是否默认(0:不默认 1:默认)*/
    private Byte               isDefault;
    /**创建时间*/
    private Date               createdDate;
    /**创建人*/
    private String             createdName;
    /**修改时间*/
    private Date               updatedDate;
    /**修改人*/
    private String             updatedName;

    /**
     * 添加或修改用户地址信息
     * @param userAddressModel
     */
    public static void validateAddOrUpdUserAddress(UserAddressModel userAddressModel) {
        if (StringUtil.isEmpty(userAddressModel.getConsignee())) {
            throw new ServiceException(UserAddressModel.CONSIGNEE_NOE_NULL);
        }
        if (StringUtil.isEmpty(userAddressModel.getConsignPhone())) {
            throw new ServiceException(UserAddressModel.CONSIGNEE_PHONE_NOE_NULL);
        }
        if (StringUtil.isEmpty(userAddressModel.getProvinceName())) {
            throw new ServiceException(UserAddressModel.PROVINCE_NAME_NOE_NULL);
        }
        if (StringUtil.isEmpty(userAddressModel.getCityName())) {
            throw new ServiceException(UserAddressModel.CITY_NAME_NOE_NULL);
        }
        if (StringUtil.isEmpty(userAddressModel.getDistrictName())) {
            throw new ServiceException(UserAddressModel.DISTRICET_NAME_NOE_NULL);
        }
        if (StringUtil.isEmpty(userAddressModel.getAddress())) {
            throw new ServiceException(UserAddressModel.ADDRESS_NOE_NULL);
        }
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public String getConsignee() {
        return consignee;
    }

    public void setConsignee(String consignee) {
        this.consignee = consignee;
    }

    public String getConsignPhone() {
        return consignPhone;
    }

    public void setConsignPhone(String consignPhone) {
        this.consignPhone = consignPhone;
    }

    public String getProvinceName() {
        return provinceName;
    }

    public void setProvinceName(String provinceName) {
        this.provinceName = provinceName;
    }

    public String getCityName() {
        return cityName;
    }

    public void setCityName(String cityName) {
        this.cityName = cityName;
    }

    public String getDistrictName() {
        return districtName;
    }

    public void setDistrictName(String districtName) {
        this.districtName = districtName;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public Byte getStatus() {
        return status;
    }

    public void setStatus(Byte status) {
        this.status = status;
    }

    public Byte getIsDefault() {
        return isDefault;
    }

    public void setIsDefault(Byte isDefault) {
        this.isDefault = isDefault;
    }

    public Date getCreatedDate() {
        return createdDate;
    }

    public void setCreatedDate(Date createdDate) {
        this.createdDate = createdDate;
    }

    public String getCreatedName() {
        return createdName;
    }

    public void setCreatedName(String createdName) {
        this.createdName = createdName;
    }

    public Date getUpdatedDate() {
        return updatedDate;
    }

    public void setUpdatedDate(Date updatedDate) {
        this.updatedDate = updatedDate;
    }

    public String getUpdatedName() {
        return updatedName;
    }

    public void setUpdatedName(String updatedName) {
        this.updatedName = updatedName;
    }

    @Override
    public String toString() {
        return "UserAddressDO [id=" + id + ", userId=" + userId + ", consignee=" + consignee
               + ", consignPhone=" + consignPhone + ", provinceName=" + provinceName
               + ", cityName=" + cityName + ", districtName=" + districtName + ", address="
               + address + ", status=" + status + ", isDefault=" + isDefault + ", createdDate="
               + createdDate + ", createdName=" + createdName + ", updatedDate=" + updatedDate
               + ", updatedName=" + updatedName + "]";
    }

}
